﻿/// <summary>
/// 元素反应：碎冰
/// </summary>
public class ElementFrozenBroken : IElementReaction
{
    private readonly IElementHolder _holder;
    private readonly IElementAura _frozenAura;

    public ElementFrozenBroken(IElementHolder holder)
    {
        _holder = holder;
        _frozenAura = _holder.GetElementAura("冻结");
    }

    public void Reaction(TriggerElementData triggerElementData)
    {
        if (_frozenAura.Gauge > 0f)
        {
            if (triggerElementData.StrikeType == StrikeType.Blunt || triggerElementData.ElementType == ElementType.Rock)
            {
                _frozenAura.Gauge = 0f;

                // 造成碎冰伤害
                var attackData = new AttackData
                {
                    Damage = 100f,
                    Source = triggerElementData.Source,
                    ElementType = ElementType.None,
                    ElementGauge = 0f,
                    StrikeType = StrikeType.None
                };
                _holder.Owner.GetComponent<ActorDamageable>().TakeDamage(attackData);
            }
        }
    }
}